<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>{:seo('title')}</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css">
    <link rel="stylesheet" href="/static/user/login/css/base.css">
    <link rel="stylesheet" href="/static/user/login/css/iconfont.css">
    <link rel="stylesheet" href="/static/user/login/css/reg.css">
</head>
<body>
<div id="ajax-hook"></div>
<div class="wrap">
    <div class="wpn">
        <div class="form-data pos">
            <form id="login_form" class="layui-form" action="{:url('user/index/login')}" method="post">
            <a href=""><img src="/static/user/login/img/logo.png" class="head-logo"></a>
            <div class="change-login">
                <p class="account_number on">账号登录</p>
                <p class="message">短信登录</p>
            </div>
            <div class="form1">
                <p class="p-input pos">
                    <label for="num">手机号码</label>
                    <input type="mobile" name="mobile" id="username" data-required="required" autocomplete="off">
                    <span class="tel-warn num-err hide"><em>账号或密码错误，请重新输入</em><i class="icon-warn"></i></span>
                </p>
                <p class="p-input pos">
                    <label for="pass">请输入密码</label>
                    <input type="password" class="aui-input" id="password" name="password" data-required="required" autocomplete="off">
                    <span class="tel-warn pass-err hide"><em>账号或密码错误，请重新输入</em><i class="icon-warn"></i></span>
                </p>
                <p class="p-input pos code">
                    <input type="checkbox" name="remember_user" id="remember_user" checked title="记住密码"  lay-skin="primary">
                </p>
            </div>
            <div class="form2 hide">
                <p class="p-input pos">
                    <label for="num2">手机号</label>
                    <input type="number" id="num2">
                    <span class="tel-warn num2-err hide"><em>账号或密码错误</em><i class="icon-warn"></i></span>
                </p>
                <p class="p-input pos">
                    <label for="veri-code">输入验证码</label>
                    <input type="number" id="veri-code">
                    <a href="javascript:;" class="send">发送验证码</a>
                    <span class="time hide"><em>120</em>s</span>
                    <span class="tel-warn error hide">验证码错误</span>
                </p>
            </div>
            <div class="r-forget cl">
                <a href="./reg.html" class="z">账号注册</a>
                <a href="./getpass.html" class="y">忘记密码</a>
            </div>
            <button class="lang-btn off log-btn" lay-submit lay-filter="login"/>登 录</button>
            <div class="third-party hide">
                <a href="#" class="log-qq icon-qq-round"></a>
                <a href="#" class="log-qq icon-weixin"></a>
                <a href="#" class="log-qq icon-sina1"></a>
            </div>
            </form>
            <p class="right">Powered by © {:seo('copyright')}</p>
        </div>
    </div>
</div>
<script src="/static/user/login/js/jquery.js"></script>
<script src="/static/user/login/js/agree.js"></script>
<script src="/static/js/jquery.cookie.js"></script>
<script src="/static/layuiadmin/layui/layui.js"></script>
<script src="/static/user/login/js/login.js"></script>
<script>
            layui.use(['layer', 'form', 'jquery'], function(){
                var layer = layui.layer,
                    form  = layui.form,
                    $     = layui.jquery;

                form.on('submit(login)', function(data) {
                    var index = layer.msg('登录中，请稍候', {
                        icon: 16,
                        time: false,
                        shade: 0.3
                    });
                    if ($("#remember_user").prop("checked") == true) {
                            var user_name = $("#username").val();
                            var user_password = $("#password").val();
                            $.cookie("remember_user", "true", {
                                    expires: 7
                            }); // 存储一个带7天期限的 cookie
                            $.cookie("user_name", user_name, {
                                    expires: 7
                            }); // 存储一个带7天期限的 cookie
                            $.cookie("user_password", user_password, {
                                    expires: 7
                            }); // 存储一个带7天期限的 cookie
                    } else {
                            $.cookie("remember_user", "false", {
                                    expires: -1
                            }); // 删除 cookie
                            $.cookie("user_name", '', {
                                    expires: -1
                            });
                            $.cookie("user_password", '', {
                                    expires: -1
                            });
                    }
                    $.ajax({
                        url: data.form.action,
                        type: data.form.method,
                        dataType: 'json',
                        data: $(data.form).serialize(),
                        success: function(result) {
                            if (result.code === 1) {
                                location.href = result.url;
                            } else {
                                $('.captcha img').attr('src', '{:url("user/index/captcha")}?rand='+Math.random());
                                layer.close(index);
                                layer.msg(result.msg);
                            }
                        },
                        error: function (xhr, state, errorThrown) {
                            layer.close(index);
                            layer.msg(state + '：' + errorThrown);
                        }
                    });
                    return false;
                });
                //

            });

        </script>
        <script>
            $(function() {
                if ($.cookie("remember_user")) {
                        $("#remember_user").prop("checked", true);
                        $("#username").val($.cookie("user_name"));
                        $("#password").val($.cookie("user_password"));
                        // 输入框内容变化按钮颜色发生变化
                        $(".form-data input").siblings("label").hide();
                        $(".log-btn").removeClass("off")
                }
        });

        function saveUserInfo() {

        }
        </script>
</body>
</html>